use enigo::Key;

// - 键盘映射
pub fn string_to_key(k: &str) -> Option<Key> {
    match k {
        "Escape" => Some(Key::Escape),
        "F1" => Some(Key::F1),
        "F2" => Some(Key::F2),
        "F3" => Some(Key::F3),
        "F4" => Some(Key::F4),
        "F5" => Some(Key::F5),
        "F6" => Some(Key::F6),
        "F7" => Some(Key::F7),
        "F8" => Some(Key::F8),
        "F9" => Some(Key::F9),
        "F10" => Some(Key::F10),
        "F11" => Some(Key::F11),
        "F12" => Some(Key::F12),
        "Backquote" => Some(Key::Layout('`')),
        "Digit1" => Some(Key::Layout('1')),
        "Digit2" => Some(Key::Layout('2')),
        "Digit3" => Some(Key::Layout('3')),
        "Digit4" => Some(Key::Layout('4')),
        "Digit5" => Some(Key::Layout('5')),
        "Digit6" => Some(Key::Layout('6')),
        "Digit7" => Some(Key::Layout('7')),
        "Digit8" => Some(Key::Layout('8')),
        "Digit9" => Some(Key::Layout('9')),
        "Digit0" => Some(Key::Layout('0')),
        "Minus" => Some(Key::Layout('-')),
        "Equal" => Some(Key::Layout('=')),
        "Backspace" => Some(Key::Backspace),
        "Tab" => Some(Key::Tab),
        "q" => Some(Key::Layout('q')),
        "w" => Some(Key::Layout('w')),
        "e" => Some(Key::Layout('e')),
        "r" => Some(Key::Layout('r')),
        "t" => Some(Key::Layout('t')),
        "y" => Some(Key::Layout('y')),
        "u" => Some(Key::Layout('u')),
        "i" => Some(Key::Layout('i')),
        "o" => Some(Key::Layout('o')),
        "p" => Some(Key::Layout('p')),
        "BracketLeft" => Some(Key::Layout('[')),
        "BracketRight" => Some(Key::Layout(']')),
        "Backslash" => Some(Key::Layout('\\')),
        "CapsLock" => Some(Key::CapsLock),
        "a" => Some(Key::Layout('a')),
        "s" => Some(Key::Layout('s')),
        "d" => Some(Key::Layout('d')),
        "f" => Some(Key::Layout('f')),
        "g" => Some(Key::Layout('g')),
        "h" => Some(Key::Layout('h')),
        "j" => Some(Key::Layout('j')),
        "k" => Some(Key::Layout('k')),
        "l" => Some(Key::Layout('l')),
        "Semicolon" => Some(Key::Layout(';')),
        "Quote" => Some(Key::Layout('\'')),
        "Enter" => Some(Key::Return),
        "Shift" => Some(Key::LShift),
        "z" => Some(Key::Layout('z')),
        "x" => Some(Key::Layout('x')),
        "c" => Some(Key::Layout('c')),
        "v" => Some(Key::Layout('v')),
        "b" => Some(Key::Layout('b')),
        "n" => Some(Key::Layout('n')),
        "m" => Some(Key::Layout('m')),
        "Comma" => Some(Key::Layout(',')),
        "Period" => Some(Key::Layout('.')),
        "Slash" => Some(Key::Layout('/')),
        "Control" => Some(Key::LControl),
        "Meta" => Some(Key::Meta),
        "Alt" => Some(Key::Option),
        "Space" => Some(Key::Space),
        "ArrowUp" => Some(Key::UpArrow),
        "ArrowLeft" => Some(Key::LeftArrow),
        "ArrowDown" => Some(Key::DownArrow),
        "ArrowRight" => Some(Key::RightArrow),
        "VolumeMute" => Some(Key::VolumeMute),
        "VolumeDown" => Some(Key::VolumeDown),
        "VolumeUp" => Some(Key::VolumeUp),
        "MediaPrevTrack" => Some(Key::MediaPrevTrack),
        "MediaPlayPause" => Some(Key::MediaPlayPause),
        "MediaNextTrack" => Some(Key::MediaNextTrack),
        _ => None,
    }
}
